package com.ruoyi.leasemanagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.leasemanagement.domain.vo.LeasemanagementVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.leasemanagement.domain.Leasemanagement;
import com.ruoyi.leasemanagement.service.ILeasemanagementService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 租约管理Controller
 * 
 * @author ruoyi
 * @date 2024-10-12
 */
@RestController
@RequestMapping("/leasemanagement/leasemanagement")
public class LeasemanagementController extends BaseController
{
    @Autowired
    private ILeasemanagementService leasemanagementService;

    /**
     * 查询租约管理列表
     */
    @PreAuthorize("@ss.hasPermi('leasemanagement:leasemanagement:list')")
    @GetMapping("/list")
    public TableDataInfo list(Leasemanagement leasemanagement)
    {
        startPage();
        List<Leasemanagement> list = leasemanagementService.selectLeasemanagementList(leasemanagement);
        return getDataTable(list);


    }

    /**
     * 导出租约管理列表
     */
    @PreAuthorize("@ss.hasPermi('leasemanagement:leasemanagement:export')")
    @Log(title = "租约管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Leasemanagement leasemanagement)
    {
        List<Leasemanagement> list = leasemanagementService.selectLeasemanagementList(leasemanagement);
        ExcelUtil<Leasemanagement> util = new ExcelUtil<Leasemanagement>(Leasemanagement.class);
        util.exportExcel(response, list, "租约管理数据");
    }

    /**
     * 获取租约管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('leasemanagement:leasemanagement:query')")
    @GetMapping(value = "/{leaseId}")
    public AjaxResult getInfo(@PathVariable("leaseId") Long leaseId)
    {
        return success(leasemanagementService.selectLeasemanagementByLeaseId(leaseId));
    }

    /**
     * 新增租约管理
     */
    @PreAuthorize("@ss.hasPermi('leasemanagement:leasemanagement:add')")
    @Log(title = "租约管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Leasemanagement leasemanagement)
    {
        return toAjax(leasemanagementService.insertLeasemanagement(leasemanagement));
    }

    /**
     * 修改租约管理
     */
    @PreAuthorize("@ss.hasPermi('leasemanagement:leasemanagement:edit')")
    @Log(title = "租约管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Leasemanagement leasemanagement)
    {
        return toAjax(leasemanagementService.updateLeasemanagement(leasemanagement));
    }

    /**
     * 删除租约管理
     */
    @PreAuthorize("@ss.hasPermi('leasemanagement:leasemanagement:remove')")
    @Log(title = "租约管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{leaseIds}")
    public AjaxResult remove(@PathVariable Long[] leaseIds)
    {
        return toAjax(leasemanagementService.deleteLeasemanagementByLeaseIds(leaseIds));
    }
}
